<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>VRD内容管理系统</title>

    <!-- Bootstrap -->
    <link href="js/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
    <link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #4e4e4e
        }

        /*导航条样式*/
        .navbar {
            background-color: black;
            border: 0; /*去掉边框*/
            margin-top: 10px;
        }

        .navbar-brand > img {
            position: relative;
            bottom: 10px;
        }

        /*搜索框样式*/
        form > input {
            background-color: #383838;
            height: 30px;
            border-radius: 30px;
            border: 0;
            padding: 10px 20px;
            color: #a8a8a8;
            margin-top: 10px;
        }

        form > button {
            background-color: rgba(0, 0, 0, 0);
            color: #a8a8a8;
            border: 0;
            position: relative;
            right: 40px;
        }

        /*瀑布流相关样式*/
        .grid-item {
            width: 200px;
            margin: 0 10px 10px 0;
        }

        /*右侧边栏样式*/
        .list-group-item {
            background-color: black;
            color: #ffc600;
            border: 0;
        }

        .list-head {
            background-color: #ffc600;
            color: black;
        }

        .well {
            background-color: black;
            color: #ffc600;
            font-weight: bold;
            text-align: center;
            border: 0;
        }

        /*蓝条相关样式*/
        .blue_div {
            width: 100%;
            height: 40px;
            background-color: #0aa1ed;
            color: #ffc600;
            text-align: center;
            /*让蓝条显示在图片的上面*/
            position: absolute;
            /*底部显示*/
            bottom: 0;
            display: none; /*让元素隐藏*/
        }

        .blue_div > p {
            margin: 0;
        }

        /*图片缩放动画*/
        img {
            transition-duration: 2s; /*动画持续时间2秒*/
        }

        img:hover {
            transform: scale(1.2); /*缩放1.2倍*/
        }

        .grid-item {
            overflow: hidden; /*超出范围不显示*/
        }
    </style>
</head>
<body>
<header class="container">
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="navbar-header">
                <a class="navbar-brand" href="#">
                    <img alt="Brand" src="images/logo.png">
                </a>
            </div>
            <!--分类开始-->
            <ul class="nav navbar-nav">
                <li><a href="/">首页</a></li>
                <li v-for="c in arr"><a :href="'/index.html?cid='+c.id">{{c.name}}</a></li>
                <li>
                    <form action="">
                        <input type="text" v-model="wd" placeholder="Search">
                        <button type="button" @click="search()">
                            <i class="fa fa-search"></i>
                        </button>
                    </form>
                </li>
            </ul>
            <!--分类结束-->
            <ul class="nav navbar-nav navbar-right">
                <li><a href="javascript:void(0)" @click="admin()">管理员入口</a></li>
            </ul>
        </div>
    </nav>
</header>
<section class="container">

    <div class="row" style="margin-top: 10px">
        <div id="detail_div" class="col-md-9">
            <!--详情开始-->
            <h2>{{product.title}}</h2>
            <hr>
            <div>
                {{product.author}}发表于{{product.created}}
                <span style="float: right">
                    <i class="fa fa-eye">{{product.viewCount}}</i>
                    <i class="fa fa-thumbs-o-up">{{product.likeCount}}</i>
                </span>
            </div>
            <div style="text-align: center">
                <button class="btn btn-info" @click="like()">给作品点赞</button>
            </div>
            <div style="padding: 50px 0;overflow: hidden">
                <img :src="product.url" style="margin: 0 auto" class="img-responsive" alt="">
            </div>
            <p style="text-align: center">{{product.intro}}</p>
            <!--详情结束-->
        </div>
        <div id="right_div" class="col-md-3">
            <!--浏览最多开始-->
            <ul class="list-group">
                <li class="list-group-item list-head">
                    <h4>
                        <i class="fa fa-eye"> 浏览最多</i>
                    </h4>
                </li>
                <li v-for="p in view_arr" class="list-group-item">
                    <div class="media">
                        <div class="media-left">
                            <a href="#">
                                <img class="media-object" :src="p.url" style="width: 64px;height: 50px" alt="...">
                            </a>
                        </div>
                        <div class="media-body">
                            <a :href="'/detail.html?id='+p.id">
                                <h4 class="media-heading">{{p.title}}</h4>
                            </a>
                            {{p.author}}
                        </div>
                    </div>
                </li>

            </ul>
            <!--浏览最多结束-->
            <!--最受欢迎开始-->
            <ul class="list-group">
                <li class="list-group-item list-head">
                    <h4>
                        <i class="fa fa-thumbs-o-up"> 最受欢迎</i>
                    </h4>
                </li>
                <li v-for="p in like_arr" class="list-group-item">
                    <div class="media">
                        <div class="media-left">
                            <a href="#">
                                <img class="media-object" :src="p.url" style="width: 64px;height: 50px" alt="...">
                            </a>
                        </div>
                        <div class="media-body">
                            <a :href="'/detail.html?id='+p.id">
                                <h4 class="media-heading">{{p.title}}</h4>
                            </a>
                            {{p.author}}
                        </div>
                    </div>
                </li>

            </ul>
            <!--最受欢迎结束-->
        </div>
    </div>

</section>
<footer class="container">
    <div class="well">
        Copyright © 北京达内金桥科技有限公司版权所有 京ICP备12003709号-3
    </div>
</footer>

<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="js/jquery.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="js/bootstrap.min.js"></script>
<!--引入瀑布流相关js文件-->
<script src="js/masonry.pkgd.min.js"></script>
<!--图片加载完成事件-->
<script src="js/imagesloaded.pkgd.js"></script>

<!--引入CDN服务器的框架文件-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js"></script>

<!--引入外部的js文件-->
<script src="js/header.js"></script>
<script src="js/right.js"></script>
<script>
    let v = new Vue({
        el: "#detail_div",
        data: {
            product: {}
        },
        created: function () {
            let id = location.search.split("=")[1];
            //通过id查询作品详情数据
            axios.get("/product/selectById?id=" + id).then(function (response) {
                v.product = response.data;
            })
        },
        methods: {
            like: function () {
                axios.get("/product/likeById?id=" + v.product.id).then(function (response) {
                    if (response.data == 1) {
                        alert("点赞成功");
                        v.product.likeCount++;
                    } else {
                        alert("请不要重复点赞")
                    }
                })
            }
        }
    })
</script>
</body>
</html>